<?php
/**
 *
 *
 */
class Yz_Model_Field_String
    extends Yz_Model_Field_Abstract
{

    const DEFAULTVALUE = '';
    protected $maxLength;

    /**
     *
     */
    protected function maxLength()
    {
        $max =& $this->maxLength;
        if (null === $max)
            $max = Yz_Int::valueOf($this->fetchConfig('maxLength', 0));
        return $max;
    }



    /** Test if a value is a valid string, possibly meeting length constraint and other requirements
     *  @param mixed value
     *  @return string
     *  @throw TypeError
     */
    protected function _testValue($value)
    {
        $value = Yz_String::valueOf($value);
        if (null === $value)
            throw TypeError::_new_();
        if ("" === $value)
            $value = null;

        return $value;
    }

}
